const gulp = require("gulp"); 
var connect = require('gulp-connect');


gulp.task('watch',done=>{
    gulp.watch('page/**', gulp.series("copyPage")); 
    gulp.watch('img/**', gulp.series("copyPage")); 
    gulp.watch('js/**', gulp.series("copyPage")); 
    gulp.watch('css/**', gulp.series("copyPage"));    
    gulp.watch('iconfont/**', gulp.series("copyPage"));   
    gulp.watch('iconfont2/**', gulp.series("copyPage"));   
    done()
 }) 
 gulp.task("server", done => {
    connect.server({
        root: "dist",
        livereload: true
    })
    done();
});  
gulp.task("default", gulp.series("watch", "server")); 
 

gulp.task("copyLib",done=>{
    gulp.src("img/**").pipe(gulp.dest("dist/img"));  
    gulp.src("page/**").pipe(gulp.dest("dist/page")); 
    gulp.src("js/**").pipe(gulp.dest("dist/js")); 
    gulp.src("css/**").pipe(gulp.dest("dist/css")); 
    gulp.src("iconfont/**").pipe(gulp.dest("dist/iconfont")); 
    gulp.src("iconfont2/**").pipe(gulp.dest("dist/iconfont2")); 
    done();
})  
gulp.task('copyhtml',done => {
    gulp.src('page/*.html').pipe(gulp.dest('dist/page')).pipe(connect.reload());
    gulp.src('css/*.css').pipe(gulp.dest('dist/css')).pipe(connect.reload());
    gulp.src('img/*{jpg,png}').pipe(gulp.dest('dist/img')).pipe(connect.reload());
    gulp.src('js/*.js').pipe(gulp.dest('dist/js')).pipe(connect.reload());
    done();
});






 